//
//  HasBeenEeleased.m
//  XiangMu
//
//  Created by 康世标 on 15/10/16.
//  Copyright (c) 2015年 康世标. All rights reserved.
//

#import "HasBeenEeleased.h"

@interface HasBeenEeleased ()

@end

@implementation HasBeenEeleased

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.title = @"已发布订单";
    self.tabBarController.tabBar.hidden = YES;
  
    [self.KSTableView registerNib:[UINib nibWithNibName:@"HasBeenEeleasedCell" bundle:nil] forCellReuseIdentifier:@"ksb"];
    
    [self getRequest];
}
//获取数据
- (void)getRequest{
    
    [QingQiuShuJu getRelease:nil blcok:^(NSDictionary *dic, BOOL isOK) {
        
//        NSLog(@"--%@",dic);
        
        if ([[dic valueForKey:@"status"]intValue] == 200)
        {
            
            self.datasArr = [[dic valueForKey:@"data"] valueForKey:@"publishOrders"] ;
//             NSLog(@"---%@",self.datasArr);
            [self.KSTableView reloadData];
            
        }
    }];
}
#pragma mark -- UITbaleViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.datasArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    HasBeenEeleasedCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ksb" forIndexPath:indexPath];
    
    NSDictionary * data = [self.datasArr objectAtIndex:indexPath.row];
   

    cell.name.text = [NSString stringWithFormat:@"姓名：%@",[self getData:[data valueForKey:@"userAddr"] key:@"name"]];
    NSLog(@"---%@",data);
    cell.address.text = [NSString stringWithFormat:@"地址：%@",[self getData:data key:@"address"]];
    
    cell.weightType.text = [NSString stringWithFormat:@"体重：%@",[self getData:data key:@"weightType"]];
    
    cell.carerType.text = [NSString stringWithFormat:@"陪护类型：%@",[self getData:data key:@"carerType"]];
    
    cell.timeType.text = [NSString stringWithFormat:@"陪护时长：%@小时",[self getData:data key:@"timeType"] ];
    
    cell.remark.text = [NSString stringWithFormat:@"其他：%@",[self getData:data key:@"remark"]];
//    cell.remark.text = @"这是一个很寂寞的天下着有些伤心的雨，这是一个很在乎的我和一个无所谓的结局，曾经为了爱儿努力，曾经为了爱二逃避，逃避拿熟悉的往事逃避拿陌生的你";
    
    
    return cell;
    

}

#pragma mark -- UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
       NSDictionary * data = [self.datasArr objectAtIndex:indexPath.row];
    NSString * s = [NSString stringWithFormat:@"其他：%@",[self getData:data key:@"remark"]];
    
    CGRect  rect = [s boundingRectWithSize:CGSizeMake(kScreenW-16, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil];
    
    
    return 155 +rect.size.height;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return 0.1f;
}
- (NSString *)getData:(NSDictionary *)dic key:(NSString *)key {
    
    NSString * string = [dic valueForKey:key] ==[NSNull null]?@"":[dic valueForKey:key];
    
     return string;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
